Skip to content

model: add Beam (Reflection) - #30670

Merged
ngxson merged 1 commit into
ggml-org:masterfrom
danielhanchen:model-add-beam
Oct 16, 2026
Merged

ngxson merged 1 commit into
ggml-org:masterfrom
danielhanchen:model-add-beam

Conversation

@danielhanchen

Copy link
Copy Markdown
Contributor

Adds support for Reflection's Beam-1.0-501B-A23B (HF BeamForCausalLM): converter, model graph and a chat parser for its tool-call format. Opening as a draft because the weights are not public yet, so the real-model results below cannot be reproduced from outside at the moment.

Architecture

subsystem how it is handled
MoE, 256 experts, top-8, sigmoid routing with grouped selection build_moe_ffn; correction bias used for selection only, routed scale and normalised weights required in the GGUF
3 leading dense SwiGLU layers standard FFN path
Interleaved sliding-window (512) and NoPE full-attention layers iSWA cache; RoPE (NeoX) on the sliding layers only
Power-law query scale on the NoPE layers optional form of llm_graph_input_attn_temp, off by default
q/k RMSNorm, per-head sigmoid output gate, scaled residuals, final logit softcap in src/models/beam.cpp
Tool calls (<|channel|> + <|constrain|>xml + rfl:parameter) new harmony-xml chat parser, detected only when all three markers are present

No new ggml op.

Correctness

  • Reference parity on a tiny random checkpoint with the real layer pattern, tokenizer and routing constants, against the transformers implementation in fp32: top-1 agreement and selected-expert Jaccard 1.0 on 64, 600 and 2000 token prompts; max logit difference 6.8e-5 / 5.2e-4 / 2.0e-3.
  • test-llama-archs -a beam: OK on CPU, CUDA and Meta. test-chat, test-jinja pass.
  • Real weights: the 501B checkpoint converts, and quantized GGUFs load and generate on CUDA. Chat template renders byte-identical to apply_chat_template; multi-turn tool-call sessions (parallel calls, typed and nested arguments, long logs) pass end to end through llama-server.
  • Malformed GGUFs (missing routing keys, no sliding layer, zero temperature scale) fail at load instead of at the first decode.

Effect on other architectures

  • llama-graph.cpp: the power-law temperature is a separate branch; existing users take the old path. llm_graph_input_attn_temp gains a shape-only can_reuse, since set_input recomputes the scale every ubatch.
  • llama-vocab.cpp: Beam's </s> stays a normal token (it is plain text in its tokenizer), using the existing gemma4/plamo exception keyed on a Beam-only token. Token ids, EOG sets and attributes are unchanged on 19 upstream test vocabs and 224 local GGUFs.
  • common/jinja: the list filter accepts objects (returns the keys).
  • common/chat.cpp: the new parser is only selected for templates containing all three markers.

AI Usage

Used Claude and Local Models for testing, iteration and code design - manual verification of model / PR usage

@danielhanchen

Copy link
Copy Markdown
Contributor Author

GGUFs at https://huggingface.co/unsloth/Beam-1.0-501B-A23B-GGUF for those wanting to try them!

@CISC
CISC marked this pull request as ready for review October 16, 2026 13:41
@CISC
CISC requested review from a team and ggerganov as code owners October 16, 2026 13:41
@pwilkin

pwilkin commented Oct 16, 2026

Copy link
Copy Markdown
Member

The CUDA error is transient, will merge after all the remaining checks are OK.

@ngxson
ngxson merged commit 01fc3aa into ggml-org:master Oct 16, 2026
31 of 34 checks passed
fewtarius added a commit to SyntheticAutonomicMind/llama.cpp that referenced this pull request Oct 18, 2026
Problem: The merge of master into unstable (1f6790b) resolved
conflicts in favor of losing parts of the Kolibri-1 (ggml-org#30673) and
Beam (ggml-org#30670) commits. This caused two categories of damage:

1. Missing enum value (llama-model.h): LLM_TYPE_78B_A3_5B was absent
   from the llm_type enum, causing kolibri1.cpp to fail compilation
   with 'use of undeclared identifier'.

2. Missing model dispatch and layer fields (Beam): llama_model_beam
   struct was absent from models.h, wqkv_gate_b was absent from
   llama_layer, pattern_attn_gate_bias was absent from its declaration
   in llama-model.cpp, and the granularity_head split check for
   attn_gate_bias was absorbed into the sinks branch.

All five missing pieces are restored to match upstream commit state.
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversion jinja parser Issues related to the jinja parser model Model specific testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants